package databaseVersionControl.domain.db;

public class Column extends DBComponent {

	private DataType _type;
	private Integer _size;
	private boolean _allowNullValue = true;
	private boolean _isPrimaryKey = false;

	public Column(String name, DataType type) {
		super(name);
		this.setDatatype(type);
	}

	public Column(String name, DataType type, Integer size, boolean allowNullValues, boolean isPrimaryKey) {
		this(name, type);
		_size = size;
		_allowNullValue = allowNullValues;
		_isPrimaryKey = isPrimaryKey;
	}

	public DataType getDataType() {
		return _type;
	}

	public boolean isPrimaryKey() {
		return _isPrimaryKey;
	}

	public boolean allowNullValue() {
		return _allowNullValue;
	}

	public int getSize() {
		return _size;
	}

	private void setDatatype(DataType type) {
		if (type == null) throw new IllegalArgumentException("DataType must be defined");
		this._type = type;
	}
}